import axios from 'axios'
import global from './global'

const url = global.host

//根据参数合同明细列表数据主要字段
export function queryContractImportantList (queryParams,_this) {
    axios({
      methods: 'get',
      url: url+'/contract/getContractImportantList',
      params: {params: JSON.stringify(queryParams)}
    }).then(res => {
      //在传入的data 中有dialog.tableData 字段
      _this.dialog.tableData = res.data
      // return data;
    })

}
// 根据参数获取合同数据数量
export function queryContractListCount (queryParams,_this) {
  axios({
    methods: 'get',
    url: url+'/contract/queryContractListCount',
    params: {params: JSON.stringify(queryParams)}
  }).then(res => {
    //在传入的data 中有dialog.total 字段
    _this.dialog.total =res.data
    // return data;
  })
}


//根据配置好计费关系的合同参数合同明细列表数据主要字段
export function queryContractErpImportantList (queryParams,_this) {
  axios({
    methods: 'get',
    url: url+'/nmErpContractRelation/getContractImportantList',
    params: {params: JSON.stringify(queryParams)}
  }).then(res => {
    //在传入的data 中有dialog.tableData 字段
    _this.dialog.tableData = res.data
    // return data;
  })

}

//根据配置好计费关系的合同参数合同明细列表数据主要字段
export function queryContractErpImportantListNew (queryParams,_this) {
  axios({
    methods: 'get',
    url: url+'/nmErpContractRelation/getContractImportantList',
    params: {params: JSON.stringify(queryParams)}
  }).then(res => {
    //在传入的data 中有dialog.tableData 字段
    _this.dialog.tableDataNew = res.data
    // return data;
  })

}
// 根据参数配置好计费关系的合同数据数量
export function queryContractErpListCount (queryParams,_this) {
  axios({
    methods: 'get',
    url: url+'/nmErpContractRelation/getContractImportantCount',
    params: {params: JSON.stringify(queryParams)}
  }).then(res => {
    //在传入的data 中有dialog.total 字段
    _this.dialog.total =res.data
    // return data;
  })
}
// // 根据参数配置好计费关系的合同数据数量
// export function queryContractErpListCount (queryParams,_this) {
//   axios({
//     methods: 'get',
//     url: url+'/nmErpContractRelation/getContractImportantCount',
//     params: {params: JSON.stringify(queryParams)}
//   }).then(res => {
//     //在传入的data 中有dialog.total 字段
//     _this.dialog.total =res.data
//     // return data;
//   })
// }

// 根据参数获取合同数据数量
export function getBaseDataList (queryParams,_this) {
  let params = {dataType:queryParams}
  let urlGet = url+'/common/getBaseData'
  axios({
    methods: 'get',
    url: urlGet,
    params: {params: JSON.stringify(params)}
  }).then(res => {
    if(queryParams===1001){
      _this.signWayData =res.data
    }else if(queryParams ===2001){
      _this.businessCodingData =res.data
    }
    // return data;
  })
}

// 根据参数获取合同业务类型
export function getBaseDataParent (_this) {
  let urlGet = url+'/common/getBaseDataList'
  axios({
    methods: 'get',
    url: urlGet,
  }).then(res => {
      _this.businessCodingData =res.data
    // return data;
  })
}

// 获取网格
export function getDept(_this) {
  let urlGet = url+'/common/getDept'
  axios({
    methods: 'get',
    url: urlGet,
  }).then(res => {
    _this.depts =res.data
    // return data;
  })
}

// 根据参数获取合同数据数量
export function getDeptStaff(queryParams,_this) {
  let params = {deptId:queryParams}
  let urlGet = url+'/common/getDeptStaff'
  axios({
    methods: 'get',
    url: urlGet,
    params: {param: JSON.stringify(params)}
  }).then(res => {
      _this.staffs =res.data
    // return data;
  })
}

// 根据参数获取合同数据数量
export function downloadTemplate(address) {
  let urlGet = url+'/common/downloadWhpModel?fileName='+address
  window.open( urlGet);//跳转后台的路径
}

export function downLoadData (response) {
  let url = window.URL.createObjectURL(response.data);
  var a = document.createElement("a");
  document.body.appendChild(a);
  a.href = url;
  a.download = decodeURI(response.headers.filename);
  a.click();
  window.URL.revokeObjectURL(url);
}


